<?php



namespace App\Model;

use Illuminate\Database\Eloquent\Model;

/**
 *  声优女用户申请
 */
class HostApplyLog extends Model
{
    protected $table = 'host_apply_log';

    protected $fillable = [
        'user_id', 'status',
    ];

    //待审核
    const STATUS_ING = 0;
    //审核通过
    const STATUS_OK = 1;
    //审核不通过
    const STATUS_FAIL = 2;

    public function userProfile()
    {
        return $this->belongsTo(UserProfile::class, 'user_id', 'user_id');
    }

    public function userInfo()
    {
        return $this->belongsTo(User::class, 'user_id', 'id');
    }

    /**
     * 添加记录
     */
    static function addRecord($userId = 0, $skills = '', $wechat = '')
    {
        $model = new self();
        $model->user_id = $userId;
        $model->skills = $skills;
        $model->wechat = $wechat;
        $model->status = self::STATUS_ING;
        return $model->saveOrFail() ? 1 : 0;
    }
}
